function DoCheck() {
    var ch = document.getElementsByName("ids");
    if (document.getElementById("allSelect").checked == true) {
        for (var i = 0; i < ch.length; i++) {
            ch[i].checked = true;
        }
    } else {
        for (var i = 0; i < ch.length; i++) {
            ch[i].checked = false;
        }
    }
}

function changeTest(message,id) {
    document.getElementById(id).text = message;
}

function changeBgColor(color,id) {
    document.getElementById(id).style.backgroundColor = color;
}

function changeFontColor(color,id) {
    document.getElementById(id).style.color = color;
}

function interest(id) {
    if(confirmMessage("关注")==true){
        $.ajax({
            async: false,
            type: "POST",
            url:'/interest/insertInterest/'+id,  //后面一个id为函数传入的id
            contentType : "application/x-www-form-urlencoded; charset=utf-8",
            dataType: "text",
            complete:function () {
                window.location.reload();
            }
        })
    }
}

function removeInterest(id) {
    if(confirmMessage("取消关注")==true){
        $.ajax({
            async: false,
            type: "POST",
            url:'/interest/removeInterest/'+id,  //后面一个id为函数传入的id
            contentType : "application/x-www-form-urlencoded; charset=utf-8",
            dataType: "text",
            complete:function () {
                window.location.reload();
            }
        })
    }
}

function confirmMessage(tag) {
    var msg = "您确定要" + tag + "吗？";
    if (confirm(msg)==true){
        return true;
    }else{
        return false;
    }
}

function confirmDelete() {
    var msg = "您确定要删除吗？";
    if (confirm(msg)==true){
        return true;
    }else{
        return false;
    }
}

function confirmRecover() {
    var msg = "您确定要恢复吗？";
    if (confirm(msg)==true){
        return true;
    }else{
        return false;
    }
}

//获取相对路径
function  getPath(){
    var pathName = document.location.pathname;
    var index = pathName.substr(1).indexOf("/");
    var result = pathName.substr(0,index+1);
    return result;
}


//显示和隐藏row-actions
$(".dashboard-comment-wrap").mouseenter(function () {
    $(this).find(".row-actions").show();
})
$(".dashboard-comment-wrap").mouseleave(function () {
    $(this).find(".row-actions").hide();
})

//删除回复
function deleteComment(id) {
    if(confirmDelete()==true){
        $.ajax({
            async: false,
            type: "POST",
            url:'/post/postDetail/delete/'+id,  //后面一个id为评论的id,由函数传入的id决定
            contentType : "application/x-www-form-urlencoded; charset=utf-8",
            dataType: "text",
            complete:function () {
                window.location.reload();
            }
        })
    }
}
